package Week3.num.week3Test1.opp03;

import java.util.Random;

public class StudentTest {
    public static void main(String[] args) {

        /**
         * 创建对象
         */
        EnglishStudent stu01=new EnglishStudent("100001","张三","男",19,
                77.0,80.0,66.5);
        EnglishStudent stu02=new EnglishStudent("100002","张四","女",20,
                70.0,65.5,89.5);
        ComputerStudent stu03=new ComputerStudent("100003","张五","男",21,
                80.0,89.0,95.5,99);
        ComputerStudent stu04=new ComputerStudent("100004","张六","女",23,
                65.0,70.0,75.0,80.0);
        LiteratureStudent stu05=new LiteratureStudent("100005","张七","男",18,
                55.5,69.0,80.5,66.0);
        /**
         * 将学生对象添加到数组中
         */
        Student[]arr= {stu01,stu02,stu03,stu04,stu05};
        /**
         * 创建随机数作为随机索引并与数组arr[i]所在位置进行交换
         * 利用循环打乱数组顺序实现随机录入学生对象
         */
        Random r=new Random();
        for (int i = 0; i < arr.length; i++) {
            int flag=r.nextInt(5);
            Student temp=arr[i];
            arr[i]=arr[flag];
            arr[flag]=temp;
        }
        /**
         * 利用循环输出所有学生信息
         */
        for (int i = 0; i < arr.length; i++) {
            System.out.println("学号:"+arr[i].getStuId()+" 姓名:"+arr[i].getName()+" 性别:"+arr[i].getGender()
                    +" 年龄:"+arr[i].getAge()+" 综合成绩:"+arr[i].score());
        }
    }
}
